﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="Articles.aspx.vb" Inherits="WeightLossProject.Articles" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2 class="custom-header">Articles</h2>
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" BackColor="White" 
        BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="4" 
        DataSourceID="dsArticles" ForeColor="Black" GridLines="Horizontal" 
        PageSize="5">
                <Columns>
            <asp:TemplateField HeaderText="Article Picture">
               <ItemTemplate>
                    <a href = "ArticleDetail.aspx?AID=<%# Eval("ID") %>"><img src="<%# Eval("Picture") %>"  width="100px" /></a>
                </ItemTemplate>
            
            </asp:TemplateField>
            <asp:HyperLinkField DataNavigateUrlFields="ID" 
                DataNavigateUrlFormatString="ArticleDetail.aspx?AID={0}" DataTextField="Title" 
                HeaderText="Title" />
            <asp:TemplateField HeaderText="Article Details">
                   <ItemTemplate>
                    <a href = "ArticleDetail.aspx?AID=<%# Eval("ID") %>">
                        <%# Eval("Details").ToString().Substring(0, 70) + " ...."%> 
                    </a>
                   </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="DateAdded" HeaderText="DateAdded" 
                SortExpression="DateAdded" />
            <asp:HyperLinkField DataNavigateUrlFields="Category" 
                DataNavigateUrlFormatString="ArticlesByCategory.aspx?CID={0}" 
                DataTextField="CategoryName" HeaderText="Category" />
            <asp:TemplateField HeaderText="Written By">
                  <ItemTemplate>
                    <a href = "ProfilePage.aspx?UID=<%# Eval("UserID") %>">
                        <%# Eval("UserName")%> 
                    </a>
                   </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <FooterStyle BackColor="#CCCC99" ForeColor="Black" />
        <HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
        <SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
        <SortedAscendingCellStyle BackColor="#F7F7F7" />
        <SortedAscendingHeaderStyle BackColor="#4B4B4B" />
        <SortedDescendingCellStyle BackColor="#E5E5E5" />
        <SortedDescendingHeaderStyle BackColor="#242121" />
    </asp:GridView>
    <asp:SqlDataSource ID="dsArticles" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
        
    
        
        
        SelectCommand="SELECT [Title], [Picture], [Details], [DateAdded], [CategoryName], [UserName], [ID], [UserID], [Category] FROM [ArticleCategoryUser] ORDER BY [ID] DESC">
    </asp:SqlDataSource>
</asp:Content>
